<template>
    <ion-row>
        <ion-list class='app-mob-portlet '>
            <ion-list-header class='app-mob-portlet__header'>客户统计摘要 </ion-list-header>
                <app-actionbar :items="actionBarModelData" @itemClick="handleItemClick"></app-actionbar>
        </ion-list>
    </ion-row>
</template>


<script lang='ts'>
import { Vue, Component, Prop, Provide, Emit, Watch, Model } from 'vue-property-decorator';
import { CreateElement } from 'vue';
import { Subject, Subscription } from 'rxjs';
import { ControlInterface } from '@/interface/control';
import GlobalUiService from '@/global-ui-service/global-ui-service';
import Res_partnerService from '@/app-core/service/res-partner/res-partner-service';
import MobPartnerBreifService from '@/app-core/ctrl-service/res-partner/mob-partner-breif-portlet-service';

import  PartnerCounterCounterService  from '@/app-core/counter/partner-counter/partner-counter-counter';


@Component({
    components: {
    }
})
export default class MobPartnerBreifBase extends Vue implements ControlInterface {

    /**
     * 名称
     *
     * @type {string}
     * @memberof MobPartnerBreif
     */
    @Prop() protected name?: string;

    /**
     * 视图通讯对象
     *
     * @type {Subject<ViewState>}
     * @memberof MobPartnerBreif
     */
    @Prop() protected viewState!: Subject<ViewState>;

    /**
     * 应用上下文
     *
     * @type {*}
     * @memberof MobPartnerBreif
     */
    @Prop({ default: {} }) protected context?: any;

    /**
     * 视图参数
     *
     * @type {*}
     * @memberof MobPartnerBreif
     */
    @Prop({ default: {} }) protected viewparams?: any;

    /**
     * 视图状态事件
     *
     * @protected
     * @type {(Subscription | undefined)}
     * @memberof MobPartnerBreif
     */
    protected viewStateEvent: Subscription | undefined;

    /**
     * 获取部件类型
     *
     * @returns {string}
     * @memberof MobPartnerBreif
     */
    protected getControlType(): string {
        return 'PORTLET'
    }

    /**
     * 全局 ui 服务
     *
     * @private
     * @type {GlobalUiService}
     * @memberof MobPartnerBreif
     */
    private globaluiservice: GlobalUiService = new GlobalUiService();

    /**
     * 建构部件服务对象
     *
     * @type {MobPartnerBreifService}
     * @memberof MobPartnerBreif
     */
    protected service: MobPartnerBreifService = new MobPartnerBreifService();

    /**
     * 实体服务对象
     *
     * @type {Res_partnerService}
     * @memberof MobPartnerBreif
     */
    protected appEntityService: Res_partnerService = new Res_partnerService();
    

    /**
     * 逻辑事件
     *
     * @protected
     * @param {*} [params={}]
     * @param {*} [tag]
     * @param {*} [$event]
     * @returns {Promise<any>}
     * @memberof Dashboard_sysportlet3Base
     */
    protected async dashboard_sysportlet3_ua434863_click(params: any = {}, tag?: any, $event?: any): Promise<any> {

        // 取数
        let datas: any[] = [];
        let xData: any = null;
        // _this 指向容器对象
        const _this: any = this;
        let contextJO: any = {};
        let paramJO: any = {};
        
        xData = this;
        if (_this.getDatas && _this.getDatas instanceof Function) {
            datas = [..._this.getDatas()];
        }
        // 界面行为
        const curUIService: any = await this.globaluiservice.getService('res_partner_ui_action');
        if (curUIService) {
            curUIService.Res_partner_OpenOrderList(datas, contextJO, paramJO, $event, xData, this);
        }
    }

    /**
     * 逻辑事件
     *
     * @protected
     * @param {*} [params={}]
     * @param {*} [tag]
     * @param {*} [$event]
     * @returns {Promise<any>}
     * @memberof Dashboard_sysportlet3Base
     */
    protected async dashboard_sysportlet3_uec1852b_click(params: any = {}, tag?: any, $event?: any): Promise<any> {

        // 取数
        let datas: any[] = [];
        let xData: any = null;
        // _this 指向容器对象
        const _this: any = this;
        let contextJO: any = {};
        let paramJO: any = {};
        
        xData = this;
        if (_this.getDatas && _this.getDatas instanceof Function) {
            datas = [..._this.getDatas()];
        }
        // 界面行为
        const curUIService: any = await this.globaluiservice.getService('res_partner_ui_action');
        if (curUIService) {
            curUIService.Res_partner_OpenAccountInvoicesList2(datas, contextJO, paramJO, $event, xData, this);
        }
    }

    /**
     * 逻辑事件
     *
     * @protected
     * @param {*} [params={}]
     * @param {*} [tag]
     * @param {*} [$event]
     * @returns {Promise<any>}
     * @memberof Dashboard_sysportlet3Base
     */
    protected async dashboard_sysportlet3_u4d39f42_click(params: any = {}, tag?: any, $event?: any): Promise<any> {

        // 取数
        let datas: any[] = [];
        let xData: any = null;
        // _this 指向容器对象
        const _this: any = this;
        let contextJO: any = {};
        let paramJO: any = {};
        
        xData = this;
        if (_this.getDatas && _this.getDatas instanceof Function) {
            datas = [..._this.getDatas()];
        }
        // 界面行为
        const curUIService: any = await this.globaluiservice.getService('res_partner_ui_action');
        if (curUIService) {
            curUIService.Res_partner_OpenAccountInvoicesList(datas, contextJO, paramJO, $event, xData, this);
        }
    }

    /**
     * 关闭视图
     *
     * @param {any[]} args
     * @memberof MobPartnerBreif
     */
    protected closeView(args: any[]): void {
        let _this: any = this;
        _this.$emit('closeview', args);
    }


    
    /**
     * PartnerCounterCounterService计数器服务对象
     *
     * @type {PartnerCounterCounterService}
     * @memberof MobPartnerBreif
     */
    protected PartnerCountercounterservice: PartnerCounterCounterService = new PartnerCounterCounterService();

    /**
     * 计数器服务对象集合
     *
     * @type {Array<*>}
     * @memberof MobPartnerBreif
     */    
    protected counterServiceArray:Array<any> = [this.PartnerCountercounterservice];


    /**
     * 操作栏模型数据
     *
     * @protected
     * @type {any[]}
     * @memberof MobPartnerBreif
     */
    protected actionBarModelData: any[] = [
        {
            viewlogicname: "dashboard_sysportlet3_ua434863_click",
            actionName: "订单总额",
            counterService:this.PartnerCountercounterservice,
            counterId: "item3",
        },
        {
            viewlogicname: "dashboard_sysportlet3_uec1852b_click",
            actionName: "已开票额",
            counterService:this.PartnerCountercounterservice,
            counterId: "item2",
        },
        {
            viewlogicname: "dashboard_sysportlet3_u4d39f42_click",
            actionName: "开票总额",
        }
    ];

    /**
     * 触发界面行为
     *
     * @protected
     * @param {*} $event
     * @memberof MobPartnerBreif
     */
    protected handleItemClick($event: any) {
        if (Object.is($event, 'dashboard_sysportlet3_ua434863_click')) {
            this.dashboard_sysportlet3_ua434863_click(null);
        }
        if (Object.is($event, 'dashboard_sysportlet3_uec1852b_click')) {
            this.dashboard_sysportlet3_uec1852b_click(null);
        }
        if (Object.is($event, 'dashboard_sysportlet3_u4d39f42_click')) {
            this.dashboard_sysportlet3_u4d39f42_click(null);
        }
    }

    /**
     * 获取多项数据
     *
     * @returns {any[]}
     * @memberof MobPartnerBreif
     */
    public getDatas(): any[] {
        return [];
    }

    /**
     * 获取单项树
     *
     * @returns {*}
     * @memberof MobPartnerBreif
     */
    public getData(): any {
        return {};
    }

    /**
     * vue 生命周期
     *
     * @memberof MobPartnerBreif
     */
    protected created() {
        this.afterCreated();
    }

    /**
     * 执行created后的逻辑
     *
     *  @memberof MobPartnerBreif
     */    
    protected afterCreated(){
        if (this.viewState) {
            this.viewStateEvent = this.viewState.subscribe(({ tag, action, data }) => {
                if (!Object.is(tag, this.name)) {
                    return;
                }
                const refs: any = this.$refs;
                Object.keys(refs).forEach((name: string) => {
                    this.viewState.next({ tag: name, action: action, data: data });
                });
            });
        }
    }

    /**
     * vue 生命周期
     *
     * @memberof MobPartnerBreif
     */
    protected destroyed() {
        this.afterDestroy();
    }

    /**
     * 执行destroyed后的逻辑
     *
     * @memberof MobPartnerBreif
     */
    protected afterDestroy() {
        if (this.viewStateEvent) {
            this.viewStateEvent.unsubscribe();
        }
    }

}
</script>

<style lang='less'>
@import './mob-partner-breif-portlet.less';
</style>